
function ConvertTo-ReadableTimeSpan {
    Param(
        [AllowNull()]
        [Parameter(Mandatory = $false)][TimeSpan]$TimeSpan = (New-TimeSpan)
    )

    if ($TimeSpan.TotalSeconds -lt 1) {
        return "0 seconds"
    }

    # Split the timespan into variables.
    $days = $TimeSpan.Days
    $hours = $TimeSpan.Hours
    $minutes = $TimeSpan.Minutes
    $seconds = $TimeSpan.Seconds

    $ReturnString = ''

    # Generate string.
    if ($days -gt 0) {
        if ($days -eq 1) {
            $ReturnString += "$days day, "
        } else {
            $ReturnString += "$days days, "
        }
    }
    if (($hours -gt 0) -or ($days -gt 0)) {
        if ($hours -eq 1) {
            $ReturnString += "$hours hour, "
        } else {
            $ReturnString += "$hours hours, "
        }
    }
    if (($minutes -gt 0) -or ($hours -gt 0) -or ($days -gt 0)) {
        if ($minutes -eq 1) {
            $ReturnString += "$minutes minute and "
        } else {
            $ReturnString += "$minutes minutes and "
        }
    }
    if (($seconds -gt 0) -or ($hours -gt 0) -or ($minutes -gt 0) -or ($days -gt 0)) {
        if ($seconds -eq 1) {
            $ReturnString += "$seconds second"
        } else {
            $ReturnString += "$seconds seconds"
        }
    }
    return $ReturnString

    <#
    .SYNOPSIS
        [TimeSpan] -> Readable string.
    .DESCRIPTION
        Turns a timespan into a readable string.
    .EXAMPLE
        PS C:\> ConvertTo-ReadableTimeSpan

        0 seconds
    .EXAMPLE
        PS C:\> $start = Get-Date
        PS C:\> $end = (Get-Date).AddDays(0.73)
        PS C:\> $timeSpan = New-TimeSpan -start $start -end $end
        PS C:\> ConvertTo-ReadableTimeSpan -TimeSpan $timeSpan

        17 hours, 31 minutes and 13 seconds
    .EXAMPLE
        PS C:\> $start = Get-Date
        PS C:\> $end = (Get-Date).AddDays(1.01)
        PS C:\> $timeSpan = New-TimeSpan -start $start -end $end
        PS C:\> ConvertTo-ReadableTimeSpan -TimeSpan $timeSpan

        1 day, 0 hours, 14 minutes and 25 seconds
    .EXAMPLE
        PS C:\> Get-HumanizeDuration -Duration $(New-TimeSpan -Start ([DateTime]::Today) -End ([DateTime]::Now))

        20 hours, 0 minutes and 57 seconds
        (Or whatever the time is)
    .INPUTS
        None. You cannot pipe objects to ConvertTo-ReadableTimeSpan.
    .OUTPUTS
        String.
    .PARAMETER TimeSpan
        A 'TimeSpan' that is converted to a readable string.
        Required?                    false
        Position?                    
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
    #>
}